import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;


public class Test {

	public static void main(String[] args) {
		MySet set = new MySet();
		Set p = new TreeSet();
		Iterator j;
		Object[] q;
		for (int i=0; i<50; i++)
			p.add(i);
		System.out.println("Add NULL shoud be false\t" +set.add(null));
		System.out.println("Add 1 shoud be true\t" +set.add(1));
		System.out.println("Add 1 should be false\t" +set.add(1));
		System.out.println("Add 2 should be true\t"+set.add(2));
		System.out.println("addAll from 0 to 49 (true)\t"+set.addAll(p));
		show(set);
		System.out.println("Contains 64? should be false\t"+set.contains(64));
		System.out.println("ContainsAll 0-49 (true) \t"+set.containsAll(p));
		System.out.println("Add 64 should be true \t\t"+set.add(64));
		System.out.println("Contains 64? should be true\t"+set.contains(64));
		System.out.println("Remove 0-49 should be true\t" + set.removeAll(p));
		show(set);
		System.out.println("Size? (1)\t" + set.size());
		System.out.println("IsEmpty? (no)\t" +set.isEmpty());
		System.out.println("Now Remove ALL!");
		set.clear();
		System.out.println("IsEmpty? (yes)\t" +set.isEmpty());
		System.out.println("Add 0-49 for Iterator Test " + set.addAll(p));
		j=set.iterator();
		while (j.hasNext()){
			System.out.print(j.next() + " ");
		}
		System.out.println();
		p.clear();
		for (int i=7; i<25; i++)
			p.add(i);
		System.out.println("RetrainALl 7-24 "+ set.retainAll(p));
		show(set);
		System.out.println("To Object Array Test" );
		Object[] ar = new Object[set.size()]; 
		q = set.toArray();
		for (int i=0;i<q.length;i++)
			System.out.print(q[i]+ " ");
	}
	public static void show(Set s){
		Object[] ar = s.toArray();
		System.out.print("[ ");
		for (int i=0; i<ar.length; i++)
			System.out.print (ar[i] + " ");
		System.out.println("]");
	}
}
